<?php
/**
 * Class UserWechat
 * Desc
 * Create on 2021/11/6 1:51
 * Create by wangyafang
 */

namespace app\common\model\xyb;


use addons\xyb\XypHelper;
use think\Model;

class UserWechat extends Model
{
    // 表名
    protected $name = 'xyb_user_wechat';
    protected $append = [
        'mobile',
    ];



    public function getAvatarAttr($value)
    {

        if(!$value) {
            $avatar['avatar'] = XypHelper::xyb_full_url('/assets/addons/xyb/img/default.png');
            return $avatar['avatar'];
        } else {
            $avatar['avatar'] = XypHelper::xyb_full_url($value);
            return $avatar['avatar'];
        }
    }

    public function getNicknameAttr($value)
    {

        if(!$value) {
            return '未授权用户';
        } else {
            return $value;
        }


    }

    public function getMobileAttr($value,$data)
    {
        $userPlatModel = new UserPlat();
        return $userPlatModel->where('wechat_id',$data['id'])->value('mobile');
    }
}